package com.dliu.javadesign.create.builder;

/**
 * @author yanglei
 * date 2021/3/29 17:05
 */
public interface Item {
    String name();
    Packing doPack();
    double price();

    abstract class Burger implements Item {
        @Override
        public Packing doPack() {
            return new Packing.Paper();
        }
    }

    abstract class Drink implements Item {
        @Override
        public Packing doPack() {
            return new Packing.Bottle();
        }
    }
}

interface Packing {
    String pack();

    class Paper implements Packing{
        @Override
        public String pack() {
            return "纸包装";
        }
    }
    class Bottle implements Packing {
        @Override
        public String pack() {
            return "瓶装";
        }
    }
}

class VegBurger extends Item.Burger {
    @Override
    public String name() {
        return "蔬菜汉堡";
    }

    @Override
    public double price() {
        return 17.5;
    }
}

class ChickBurger extends Item.Burger {
    @Override
    public String name() {
        return "鸡肉汉堡";
    }

    @Override
    public double price() {
        return 19.5;
    }
}

class CokeDrink extends Item.Drink {
    @Override
    public String name() {
        return "可口可乐";
    }

    @Override
    public double price() {
        return 3.5;
    }
}

class PepsiDrink extends Item.Drink {
    @Override
    public String name() {
        return "百事可乐";
    }

    @Override
    public double price() {
        return 3;
    }
}
